<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="org.apache.catalina.tribes.util.TcclThreadFactory"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date" %>
<%@page import="java.sql.*" %>
<%@page import="org.edu.system.DBConnect" %>
<%
	String tc_id = (String)(session.getAttribute("UserName"));
	String sql = "SELECT * FROM teacher WHERE tc_id = '" + tc_id + "'";
	System.out.println(sql);
	
	Connection con = DBConnect.getCon();
	Statement stmt = null;
	ResultSet rs = null;
	stmt = con.createStatement();
	rs = stmt.executeQuery(sql);//执行命令
	if (rs.next())// 如果记录集非空，表明有匹配的用户ID
	{
			//正常进行
	} else {
		// 否则登录失败
		// response.sendRedirect ( "MyJsp.jsp" );
		response.sendRedirect("login_failure.jsp");
	}
%>
<!DOCTYPE html>
<html>
<head>
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<meta charset="UTF-8">
<title>教师教务管理系统 - 查看评教</title>
</head>
<body>
<br>
<body>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>教师教务管理系统 - 查看评教</title>
</head>
<body style="width:900px; margin:0 auto;">
	<center>
	<form method="get" name="frmLogin" >
		<div id="Container">
			<div id="edit">
				<div id="function">
				</div>
				<div id="deal">
				<table border="1" class="table table-striped table-bordered">
						<tr>
							<th><font size="2">课程名</font></th>
							<th><font size="2">评教内容</font></th>
						</tr>
					<%
					PreparedStatement pst = null;
					try{
						//1.去lesson表中查这个老师所有的课程，获取到 lesson_id 集
						String sql_select = "SELECT lesson_id FROM lesson where tc_id='"+tc_id+"'";;
						System.out.println(sql_select);
						con = DBConnect.getCon();
						request.setCharacterEncoding("utf-8");
						System.out.println(sql_select);
						pst = con.prepareStatement(sql_select);
						rs = pst.executeQuery();
						PreparedStatement pst1 = null;
						ResultSet rs1 = null;
						while(rs.next())
						{
							System.out.print("输出课程："+rs.getString("lesson_id"));
							sql = "select c.course_name,e.content from course c,evaluation e,lesson l where l.lesson_id='"+rs.getString("lesson_id")+"' and l.lesson_id=e.lesson_id and l.course_id = c.course_id";
							System.out.println(sql);
							pst1 = con.prepareStatement(sql);
							rs1 = pst1.executeQuery();
							while(rs1.next())
							{
								
					%>
					
						<%
							out.print("<tr>");
							out.print("<td width='20%'><font size=\"2\">"+rs1.getString("course_name")+"</font></td>");
							out.print("<td><font size=\"2\">"+rs1.getString("content")+"</font></td>");
							out.print("</tr>");
							}
						}}finally{}
						%>
					</table>
				</div>
			</div>
		</div>
	</form>
	</center>
</body>
</html>